home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / Source Code / Template / d3dsettings.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  36.3 KB  |  912 lines

  1. //-----------------------------------------------------------------------------
  2. // File: D3DSettings.cpp
  3. //
  4. // Desc: Settings class and change-settings dialog class for the Direct3D 
  5. //       samples framework library.
  6. //-----------------------------------------------------------------------------
  7. #define STRICT
  8. $$IF(DLG)
  9. #include "stdafx.h"
  10. $$ENDIF
  11. #include <windows.h>
  12. #include <windowsx.h>
  13. #include <tchar.h>
  14. #include <stdio.h>
  15. #include <D3D9.h>
  16. #include "DXUtil.h"
  17. #include "D3DUtil.h"
  18. #include "D3DEnumeration.h"
  19. #include "D3DSettings.h"
  20. #include "resource.h"
  21.  
  22. CD3DSettingsDialog* s_pSettingsDialog = NULL;
  23.  
  24.  
  25. //-----------------------------------------------------------------------------
  26. // Name: D3DDevTypeToString
  27. // Desc: Returns the string for the given D3DDEVTYPE.
  28. //-----------------------------------------------------------------------------
  29. TCHAR* D3DDevTypeToString(D3DDEVTYPE devType)
  30. {
  31.     switch (devType)
  32.     {
  33.     case D3DDEVTYPE_HAL:        return TEXT("D3DDEVTYPE_HAL");
  34.     case D3DDEVTYPE_SW:         return TEXT("D3DDEVTYPE_SW");
  35.     case D3DDEVTYPE_REF:        return TEXT("D3DDEVTYPE_REF");
  36.     default:                    return TEXT("Unknown devType");
  37.     }
  38. }
  39.  
  40.  
  41. //-----------------------------------------------------------------------------
  42. // Name: MultisampleTypeToString
  43. // Desc: Returns the string for the given D3DMULTISAMPLE_TYPE.
  44. //-----------------------------------------------------------------------------
  45. TCHAR* MultisampleTypeToString(D3DMULTISAMPLE_TYPE MultiSampleType)
  46. {
  47.     switch (MultiSampleType)
  48.     {
  49.     case D3DMULTISAMPLE_NONE:   return TEXT("D3DMULTISAMPLE_NONE");
  50.     case D3DMULTISAMPLE_NONMASKABLE: return TEXT("D3DMULTISAMPLE_NONMASKABLE");
  51.     case D3DMULTISAMPLE_2_SAMPLES: return TEXT("D3DMULTISAMPLE_2_SAMPLES");
  52.     case D3DMULTISAMPLE_3_SAMPLES: return TEXT("D3DMULTISAMPLE_3_SAMPLES");
  53.     case D3DMULTISAMPLE_4_SAMPLES: return TEXT("D3DMULTISAMPLE_4_SAMPLES");
  54.     case D3DMULTISAMPLE_5_SAMPLES: return TEXT("D3DMULTISAMPLE_5_SAMPLES");
  55.     case D3DMULTISAMPLE_6_SAMPLES: return TEXT("D3DMULTISAMPLE_6_SAMPLES");
  56.     case D3DMULTISAMPLE_7_SAMPLES: return TEXT("D3DMULTISAMPLE_7_SAMPLES");
  57.     case D3DMULTISAMPLE_8_SAMPLES: return TEXT("D3DMULTISAMPLE_8_SAMPLES");
  58.     case D3DMULTISAMPLE_9_SAMPLES: return TEXT("D3DMULTISAMPLE_9_SAMPLES");
  59.     case D3DMULTISAMPLE_10_SAMPLES: return TEXT("D3DMULTISAMPLE_10_SAMPLES");
  60.     case D3DMULTISAMPLE_11_SAMPLES: return TEXT("D3DMULTISAMPLE_11_SAMPLES");
  61.     case D3DMULTISAMPLE_12_SAMPLES: return TEXT("D3DMULTISAMPLE_12_SAMPLES");
  62.     case D3DMULTISAMPLE_13_SAMPLES: return TEXT("D3DMULTISAMPLE_13_SAMPLES");
  63.     case D3DMULTISAMPLE_14_SAMPLES: return TEXT("D3DMULTISAMPLE_14_SAMPLES");
  64.     case D3DMULTISAMPLE_15_SAMPLES: return TEXT("D3DMULTISAMPLE_15_SAMPLES");
  65.     case D3DMULTISAMPLE_16_SAMPLES: return TEXT("D3DMULTISAMPLE_16_SAMPLES");
  66.     default:                    return TEXT("Unknown Multisample Type");
  67.     }
  68. }
  69.  
  70.  
  71. //-----------------------------------------------------------------------------
  72. // Name: VertexProcessingTypeToString
  73. // Desc: Returns the string for the given VertexProcessingType.
  74. //-----------------------------------------------------------------------------
  75. TCHAR* VertexProcessingTypeToString(VertexProcessingType vpt)
  76. {
  77.     switch (vpt)
  78.     {
  79.     case SOFTWARE_VP:      return TEXT("SOFTWARE_VP");
  80.     case MIXED_VP:         return TEXT("MIXED_VP");
  81.     case HARDWARE_VP:      return TEXT("HARDWARE_VP");
  82.     case PURE_HARDWARE_VP: return TEXT("PURE_HARDWARE_VP");
  83.     default:               return TEXT("Unknown VertexProcessingType");
  84.     }
  85. }
  86.  
  87.  
  88. //-----------------------------------------------------------------------------
  89. // Name: PresentIntervalToString
  90. // Desc: Returns the string for the given present interval.
  91. //-----------------------------------------------------------------------------
  92. TCHAR* PresentIntervalToString( UINT pi )
  93. {
  94.     switch( pi )
  95.     {
  96.     case D3DPRESENT_INTERVAL_IMMEDIATE: return TEXT("D3DPRESENT_INTERVAL_IMMEDIATE");
  97.     case D3DPRESENT_INTERVAL_DEFAULT:   return TEXT("D3DPRESENT_INTERVAL_DEFAULT");
  98.     case D3DPRESENT_INTERVAL_ONE:       return TEXT("D3DPRESENT_INTERVAL_ONE");
  99.     case D3DPRESENT_INTERVAL_TWO:       return TEXT("D3DPRESENT_INTERVAL_TWO");
  100.     case D3DPRESENT_INTERVAL_THREE:     return TEXT("D3DPRESENT_INTERVAL_THREE");
  101.     case D3DPRESENT_INTERVAL_FOUR:      return TEXT("D3DPRESENT_INTERVAL_FOUR");
  102.     default:                            return TEXT("Unknown PresentInterval");
  103.     }
  104. }
  105.  
  106.  
  107.  
  108.  
  109. //-----------------------------------------------------------------------------
  110. // Name: DialogProcHelper
  111. // Desc: 
  112. //-----------------------------------------------------------------------------
  113. INT_PTR CALLBACK DialogProcHelper( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
  114. {
  115.     return s_pSettingsDialog->DialogProc( hDlg, msg, wParam, lParam );
  116. }
  117.  
  118.  
  119.  
  120.  
  121. //-----------------------------------------------------------------------------
  122. // Name: CD3DSettingsDialog constructor
  123. // Desc: 
  124. //-----------------------------------------------------------------------------
  125. CD3DSettingsDialog::CD3DSettingsDialog( CD3DEnumeration* pEnumeration, 
  126.                                         CD3DSettings* pSettings)
  127. {
  128.     s_pSettingsDialog = this;
  129.     m_pEnumeration = pEnumeration;
  130.     m_d3dSettings = *pSettings;
  131. }
  132.  
  133.  
  134.  
  135.  
  136. //-----------------------------------------------------------------------------
  137. // Name: ComboBoxAdd
  138. // Desc: Adds an entry to the combo box.
  139. //-----------------------------------------------------------------------------
  140. void CD3DSettingsDialog::ComboBoxAdd( int id, void* pData, TCHAR* pstrDesc )
  141. {
  142.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  143.     DWORD dwItem = ComboBox_AddString( hwndCtrl, pstrDesc );
  144.     ComboBox_SetItemData( hwndCtrl, dwItem, pData );
  145. }
  146.  
  147.  
  148.  
  149.  
  150. //-----------------------------------------------------------------------------
  151. // Name: ComboBoxSelect
  152. // Desc: Selects an entry in the combo box.
  153. //-----------------------------------------------------------------------------
  154. void CD3DSettingsDialog::ComboBoxSelect( int id, void* pData )
  155. {
  156.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  157.     UINT count = ComboBoxCount( id );
  158.     for( UINT iItem = 0; iItem < count; iItem++ )
  159.     {
  160.         if( (void*)ComboBox_GetItemData( hwndCtrl, iItem ) == pData )
  161.         {
  162.             ComboBox_SetCurSel( hwndCtrl, iItem );
  163.             PostMessage( m_hDlg, WM_COMMAND, 
  164.                 MAKEWPARAM( id, CBN_SELCHANGE ), (LPARAM)hwndCtrl );
  165.             return;
  166.         }
  167.     }
  168. }
  169.  
  170.  
  171.  
  172.  
  173. //-----------------------------------------------------------------------------
  174. // Name: ComboBoxSelectIndex
  175. // Desc: Selects an entry in the combo box.
  176. //-----------------------------------------------------------------------------
  177. void CD3DSettingsDialog::ComboBoxSelectIndex( int id, int index )
  178. {
  179.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  180.     ComboBox_SetCurSel( hwndCtrl, index );
  181.     PostMessage( m_hDlg, WM_COMMAND, MAKEWPARAM( id, CBN_SELCHANGE ), 
  182.         (LPARAM)hwndCtrl );
  183. }
  184.  
  185.  
  186.  
  187.  
  188. //-----------------------------------------------------------------------------
  189. // Name: ComboBoxSelected
  190. // Desc: Returns the data for the selected entry in the combo box.
  191. //-----------------------------------------------------------------------------
  192. void* CD3DSettingsDialog::ComboBoxSelected( int id )
  193. {
  194.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  195.     int index = ComboBox_GetCurSel( hwndCtrl );
  196.     if( index < 0 )
  197.         return NULL;
  198.     return (void*)ComboBox_GetItemData( hwndCtrl, index );
  199. }
  200.  
  201.  
  202.  
  203.  
  204. //-----------------------------------------------------------------------------
  205. // Name: ComboBoxSomethingSelected
  206. // Desc: Returns whether any entry in the combo box is selected.  This is 
  207. //       more useful than ComboBoxSelected() when you need to distinguish 
  208. //       between having no item selected vs. having an item selected whose 
  209. //       itemData is NULL.
  210. //-----------------------------------------------------------------------------
  211. bool CD3DSettingsDialog::ComboBoxSomethingSelected( int id )
  212. {
  213.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  214.     int index = ComboBox_GetCurSel( hwndCtrl );
  215.     return ( index >= 0 );
  216. }
  217.  
  218.  
  219.  
  220.  
  221. //-----------------------------------------------------------------------------
  222. // Name: ComboBoxCount
  223. // Desc: Returns the number of entries in the combo box.
  224. //-----------------------------------------------------------------------------
  225. UINT CD3DSettingsDialog::ComboBoxCount( int id )
  226. {
  227.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  228.     return ComboBox_GetCount( hwndCtrl );
  229. }
  230.  
  231.  
  232.  
  233.  
  234. //-----------------------------------------------------------------------------
  235. // Name: ComboBoxClear
  236. // Desc: Clears the entries in the combo box.
  237. //-----------------------------------------------------------------------------
  238. void CD3DSettingsDialog::ComboBoxClear( int id )
  239. {
  240.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  241.     ComboBox_ResetContent( hwndCtrl );
  242. }
  243.  
  244.  
  245.  
  246.  
  247. //-----------------------------------------------------------------------------
  248. // Name: ComboBoxContainsText
  249. // Desc: Returns whether the combo box contains the given text.
  250. //-----------------------------------------------------------------------------
  251. bool CD3DSettingsDialog::ComboBoxContainsText( int id, TCHAR* pstrText )
  252. {
  253.     TCHAR strItem[200];
  254.     HWND hwndCtrl = GetDlgItem( m_hDlg, id );
  255.     UINT count = ComboBoxCount( id );
  256.     for( UINT iItem = 0; iItem < count; iItem++ )
  257.     {
  258.         if( ComboBox_GetLBTextLen( hwndCtrl, iItem ) >= 200 )
  259.             continue; // shouldn't happen, but don't overwrite buffer if it does
  260.         ComboBox_GetLBText( hwndCtrl, iItem, strItem );
  261.         if( lstrcmp( strItem, pstrText ) == 0 )
  262.             return true;
  263.     }
  264.     return false;
  265. }
  266.  
  267.  
  268.  
  269.  
  270. //-----------------------------------------------------------------------------
  271. // Name: ShowDialog
  272. // Desc: Show the D3D settings dialog.
  273. //-----------------------------------------------------------------------------
  274. INT_PTR CD3DSettingsDialog::ShowDialog( HWND hwndParent )
  275. {
  276.     return DialogBox( NULL, MAKEINTRESOURCE( IDD_SELECTDEVICE ), 
  277.         hwndParent, DialogProcHelper );
  278. }
  279.  
  280.  
  281.  
  282.  
  283. //-----------------------------------------------------------------------------
  284. // Name: DialogProc
  285. // Desc: Handle window messages in the dialog.
  286. //-----------------------------------------------------------------------------
  287. INT_PTR CD3DSettingsDialog::DialogProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
  288. {
  289.     UNREFERENCED_PARAMETER( lParam );
  290.  
  291.     switch( msg )
  292.     {
  293.     case WM_INITDIALOG:
  294.         {
  295.             m_hDlg = hDlg;
  296.  
  297.             // Fill adapter combo box.  Updating the selected adapter will trigger
  298.             // updates of the rest of the dialog.
  299.             for( UINT iai = 0; iai < m_pEnumeration->m_pAdapterInfoList->Count(); iai++ )
  300.             {
  301.                 D3DAdapterInfo* pAdapterInfo;
  302.                 pAdapterInfo = (D3DAdapterInfo*)m_pEnumeration->m_pAdapterInfoList->GetPtr(iai);
  303.                 TCHAR strDescription[512];
  304.                 DXUtil_ConvertAnsiStringToGenericCch( strDescription, pAdapterInfo->AdapterIdentifier.Description, 512 );
  305.                 ComboBoxAdd( IDC_ADAPTER_COMBO, pAdapterInfo, strDescription );
  306.                 if( pAdapterInfo->AdapterOrdinal == m_d3dSettings.AdapterOrdinal() )
  307.                     ComboBoxSelect( IDC_ADAPTER_COMBO, pAdapterInfo );
  308.             }
  309.             if( !ComboBoxSomethingSelected( IDC_ADAPTER_COMBO ) &&
  310.                 ComboBoxCount( IDC_ADAPTER_COMBO ) > 0 )
  311.             {
  312.                 ComboBoxSelectIndex( IDC_ADAPTER_COMBO, 0 );
  313.             }
  314.         }
  315.         return TRUE;
  316.  
  317.     case WM_COMMAND:
  318.         switch( LOWORD(wParam) )
  319.         {
  320.         case IDOK:
  321.             EndDialog( hDlg, IDOK );
  322.             break;
  323.         case IDCANCEL:
  324.             EndDialog( hDlg, IDCANCEL );
  325.             break;
  326.         case IDC_ADAPTER_COMBO:
  327.             if( CBN_SELCHANGE == HIWORD(wParam) )
  328.                 AdapterChanged();
  329.             break;
  330.         case IDC_DEVICE_COMBO:
  331.             if( CBN_SELCHANGE == HIWORD(wParam) )
  332.                 DeviceChanged();
  333.             break;
  334.         case IDC_ADAPTERFORMAT_COMBO:
  335.             if( CBN_SELCHANGE == HIWORD(wParam) )
  336.                 AdapterFormatChanged();
  337.             break;
  338.         case IDC_RESOLUTION_COMBO:
  339.             if( CBN_SELCHANGE == HIWORD(wParam) )
  340.                 ResolutionChanged();
  341.             break;
  342.         case IDC_REFRESHRATE_COMBO:
  343.             if( CBN_SELCHANGE == HIWORD(wParam) )
  344.                 RefreshRateChanged();
  345.             break;
  346.         case IDC_BACKBUFFERFORMAT_COMBO:
  347.             if( CBN_SELCHANGE == HIWORD(wParam) )
  348.                 BackBufferFormatChanged();
  349.             break;
  350.         case IDC_DEPTHSTENCILBUFFERFORMAT_COMBO:
  351.             if( CBN_SELCHANGE == HIWORD(wParam) )
  352.                 DepthStencilBufferFormatChanged();
  353.             break;
  354.         case IDC_MULTISAMPLE_COMBO:
  355.             if( CBN_SELCHANGE == HIWORD(wParam) )
  356.                 MultisampleTypeChanged();
  357.             break;
  358.         case IDC_MULTISAMPLE_QUALITY_COMBO:
  359.             if( CBN_SELCHANGE == HIWORD(wParam) )
  360.                 MultisampleQualityChanged();
  361.             break;
  362.         case IDC_VERTEXPROCESSING_COMBO:
  363.             if( CBN_SELCHANGE == HIWORD(wParam) )
  364.                 VertexProcessingChanged();
  365.             break;
  366.         case IDC_PRESENTINTERVAL_COMBO:
  367.             if( CBN_SELCHANGE == HIWORD(wParam) )
  368.                 PresentIntervalChanged();
  369.             break;
  370.         case IDC_WINDOW:
  371.         case IDC_FULLSCREEN:
  372.             WindowedFullscreenChanged();
  373.             break;
  374.         }
  375.         return TRUE;
  376.  
  377.     default:
  378.         return FALSE;
  379.     }
  380. }
  381.  
  382.  
  383.  
  384. //-----------------------------------------------------------------------------
  385. // Name: AdapterChanged
  386. // Desc: Respond to a change of selected adapter.
  387. //-----------------------------------------------------------------------------
  388. void CD3DSettingsDialog::AdapterChanged( void )
  389. {
  390.     D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO );
  391.     if( pAdapterInfo == NULL )
  392.         return;
  393.     
  394.     if( m_d3dSettings.IsWindowed )
  395.         m_d3dSettings.pWindowed_AdapterInfo = pAdapterInfo;
  396.     else
  397.         m_d3dSettings.pFullscreen_AdapterInfo = pAdapterInfo;
  398.  
  399.     // Update device combo box
  400.     ComboBoxClear( IDC_DEVICE_COMBO );
  401.     for( UINT idi = 0; idi < pAdapterInfo->pDeviceInfoList->Count(); idi++ )
  402.     {
  403.         D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)pAdapterInfo->pDeviceInfoList->GetPtr(idi);
  404.         ComboBoxAdd( IDC_DEVICE_COMBO, pDeviceInfo, 
  405.                      D3DDevTypeToString( pDeviceInfo->DevType ) );
  406.         if( pDeviceInfo->DevType == m_d3dSettings.DevType() )
  407.             ComboBoxSelect( IDC_DEVICE_COMBO, pDeviceInfo );
  408.     }
  409.     if( !ComboBoxSomethingSelected( IDC_DEVICE_COMBO ) &&
  410.         ComboBoxCount( IDC_DEVICE_COMBO ) > 0 )
  411.     {
  412.         ComboBoxSelectIndex( IDC_DEVICE_COMBO, 0 );
  413.     }
  414. }
  415.  
  416.  
  417.  
  418.  
  419. //-----------------------------------------------------------------------------
  420. // Name: DeviceChanged
  421. // Desc: Respond to a change of selected device by resetting the 
  422. //       fullscreen/windowed radio buttons.  Updating these buttons will 
  423. //       trigger updates of the rest of the dialog.
  424. //-----------------------------------------------------------------------------
  425. void CD3DSettingsDialog::DeviceChanged( void )
  426. {
  427.     D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO );
  428.     if( pDeviceInfo == NULL )
  429.         return;
  430.  
  431.     if( m_d3dSettings.IsWindowed )
  432.         m_d3dSettings.pWindowed_DeviceInfo = pDeviceInfo;
  433.     else
  434.         m_d3dSettings.pFullscreen_DeviceInfo = pDeviceInfo;
  435.  
  436.     // Update fullscreen/windowed radio buttons
  437.     bool HasWindowedDeviceCombo = false;
  438.     bool HasFullscreenDeviceCombo = false;
  439.     for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ )
  440.     {
  441.         D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc);
  442.         if( pDeviceCombo->IsWindowed )
  443.             HasWindowedDeviceCombo = true;
  444.         else
  445.             HasFullscreenDeviceCombo = true;
  446.     }
  447.     EnableWindow( GetDlgItem( m_hDlg, IDC_WINDOW ), HasWindowedDeviceCombo );
  448.     EnableWindow( GetDlgItem( m_hDlg, IDC_FULLSCREEN ), HasFullscreenDeviceCombo );
  449.     if (m_d3dSettings.IsWindowed && HasWindowedDeviceCombo)
  450.     {
  451.         CheckRadioButton( m_hDlg, IDC_WINDOW, IDC_FULLSCREEN, IDC_WINDOW );
  452.     }
  453.     else
  454.     {
  455.         CheckRadioButton( m_hDlg, IDC_WINDOW, IDC_FULLSCREEN, IDC_FULLSCREEN );
  456.     }
  457.     WindowedFullscreenChanged();
  458. }
  459.  
  460.  
  461.  
  462.  
  463. //-----------------------------------------------------------------------------
  464. // Name: WindowedFullscreenChanged
  465. // Desc: Respond to a change of windowed/fullscreen state by rebuilding the
  466. //       adapter format list, resolution list, and refresh rate list.
  467. //       Updating the selected adapter format will trigger updates of the 
  468. //       rest of the dialog.
  469. //-----------------------------------------------------------------------------
  470. void CD3DSettingsDialog::WindowedFullscreenChanged( void )
  471. {
  472.     D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO );
  473.     D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO );
  474.     if( pAdapterInfo == NULL || pDeviceInfo == NULL )
  475.         return;
  476.  
  477.     if( IsDlgButtonChecked( m_hDlg, IDC_WINDOW ) )
  478.     {
  479.         m_d3dSettings.IsWindowed = true;
  480.         m_d3dSettings.pWindowed_AdapterInfo = pAdapterInfo;
  481.         m_d3dSettings.pWindowed_DeviceInfo = pDeviceInfo;
  482.  
  483.         // Update adapter format combo box
  484.         ComboBoxClear( IDC_ADAPTERFORMAT_COMBO );
  485.         ComboBoxAdd( IDC_ADAPTERFORMAT_COMBO, (void*)m_d3dSettings.Windowed_DisplayMode.Format,
  486.             D3DUtil_D3DFormatToString( m_d3dSettings.Windowed_DisplayMode.Format ) );
  487.         ComboBoxSelectIndex( IDC_ADAPTERFORMAT_COMBO, 0 );
  488.         EnableWindow( GetDlgItem( m_hDlg, IDC_ADAPTERFORMAT_COMBO ), false );
  489.  
  490.         // Update resolution combo box
  491.         DWORD dwResolutionData;
  492.         TCHAR strResolution[50];
  493.         dwResolutionData = MAKELONG( m_d3dSettings.Windowed_DisplayMode.Width,
  494.                                      m_d3dSettings.Windowed_DisplayMode.Height );
  495.         _sntprintf( strResolution, 50, TEXT("%d by %d"), m_d3dSettings.Windowed_DisplayMode.Width, 
  496.             m_d3dSettings.Windowed_DisplayMode.Height );
  497.         strResolution[49] = 0;
  498.         ComboBoxClear( IDC_RESOLUTION_COMBO );
  499.         ComboBoxAdd( IDC_RESOLUTION_COMBO, ULongToPtr(dwResolutionData), strResolution );
  500.         ComboBoxSelectIndex( IDC_RESOLUTION_COMBO, 0 );
  501.         EnableWindow( GetDlgItem( m_hDlg, IDC_RESOLUTION_COMBO ), false );
  502.  
  503.         // Update refresh rate combo box
  504.         TCHAR strRefreshRate[50];
  505.         if( m_d3dSettings.Windowed_DisplayMode.RefreshRate == 0 )
  506.             lstrcpy( strRefreshRate, TEXT("Default Rate") );
  507.         else
  508.             _sntprintf( strRefreshRate, 50, TEXT("%d Hz"), m_d3dSettings.Windowed_DisplayMode.RefreshRate );
  509.         strRefreshRate[49] = 0;
  510.         ComboBoxClear( IDC_REFRESHRATE_COMBO );
  511.         ComboBoxAdd( IDC_REFRESHRATE_COMBO, ULongToPtr(m_d3dSettings.Windowed_DisplayMode.RefreshRate),
  512.             strRefreshRate );
  513.         ComboBoxSelectIndex( IDC_REFRESHRATE_COMBO, 0 );
  514.         EnableWindow( GetDlgItem( m_hDlg, IDC_REFRESHRATE_COMBO ), false );
  515.     }
  516.     else
  517.     {
  518.         m_d3dSettings.IsWindowed = false;
  519.         m_d3dSettings.pFullscreen_AdapterInfo = pAdapterInfo;
  520.         m_d3dSettings.pFullscreen_DeviceInfo = pDeviceInfo;
  521.  
  522.         // Update adapter format combo box
  523.         ComboBoxClear( IDC_ADAPTERFORMAT_COMBO );
  524.         for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ )
  525.         {
  526.             D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc);
  527.             D3DFORMAT adapterFormat = pDeviceCombo->AdapterFormat;
  528.             if( !ComboBoxContainsText( IDC_ADAPTERFORMAT_COMBO, D3DUtil_D3DFormatToString( adapterFormat ) ) )
  529.             {
  530.                 ComboBoxAdd( IDC_ADAPTERFORMAT_COMBO, (void*)adapterFormat, 
  531.                     D3DUtil_D3DFormatToString( adapterFormat ) );
  532.                 if( adapterFormat == m_d3dSettings.Fullscreen_DisplayMode.Format )
  533.                 {
  534.                     ComboBoxSelect( IDC_ADAPTERFORMAT_COMBO, (void*)adapterFormat );
  535.                 }
  536.             }
  537.         }
  538.         if( !ComboBoxSomethingSelected( IDC_ADAPTERFORMAT_COMBO ) &&
  539.             ComboBoxCount( IDC_ADAPTERFORMAT_COMBO ) > 0 )
  540.         {
  541.             ComboBoxSelectIndex( IDC_ADAPTERFORMAT_COMBO, 0 );
  542.         }
  543.         EnableWindow( GetDlgItem( m_hDlg, IDC_ADAPTERFORMAT_COMBO), true );
  544.         
  545.         // Update resolution combo box
  546.         EnableWindow( GetDlgItem( m_hDlg, IDC_RESOLUTION_COMBO), true );
  547.         
  548.         // Update refresh rate combo box
  549.         EnableWindow( GetDlgItem( m_hDlg, IDC_REFRESHRATE_COMBO), true );
  550.     }
  551. }
  552.  
  553.  
  554.  
  555.  
  556. //-----------------------------------------------------------------------------
  557. // Name: AdapterFormatChanged
  558. // Desc: Respond to a change of selected adapter format by rebuilding the
  559. //       resolution list and back buffer format list.  Updating the selected 
  560. //       resolution and back buffer format will trigger updates of the rest 
  561. //       of the dialog.
  562. //-----------------------------------------------------------------------------
  563. void CD3DSettingsDialog::AdapterFormatChanged( void )
  564. {
  565.     if( !IsDlgButtonChecked( m_hDlg, IDC_WINDOW ) )
  566.     {
  567.         D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO );
  568.         D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) );
  569.         m_d3dSettings.Fullscreen_DisplayMode.Format = adapterFormat;
  570.  
  571.         ComboBoxClear( IDC_RESOLUTION_COMBO );
  572.         for( UINT idm = 0; idm < pAdapterInfo->pDisplayModeList->Count(); idm++ )
  573.         {
  574.             D3DDISPLAYMODE displayMode = *(D3DDISPLAYMODE*)pAdapterInfo->pDisplayModeList->GetPtr(idm);
  575.             if (displayMode.Format == adapterFormat)
  576.             {
  577.                 DWORD dwResolutionData;
  578.                 TCHAR strResolution[50];
  579.                 dwResolutionData = MAKELONG( displayMode.Width, displayMode.Height );
  580.                 _sntprintf( strResolution, 50, TEXT("%d by %d"), displayMode.Width, displayMode.Height );
  581.                 strResolution[49] = 0;
  582.                 if (!ComboBoxContainsText( IDC_RESOLUTION_COMBO, strResolution ) )
  583.                 {
  584.                     ComboBoxAdd( IDC_RESOLUTION_COMBO, ULongToPtr( dwResolutionData ), strResolution );
  585.                     if (m_d3dSettings.Fullscreen_DisplayMode.Width == displayMode.Width &&
  586.                         m_d3dSettings.Fullscreen_DisplayMode.Height == displayMode.Height)
  587.                     {
  588.                         ComboBoxSelect( IDC_RESOLUTION_COMBO, ULongToPtr( dwResolutionData ) );
  589.                     }
  590.                 }
  591.             }
  592.         }
  593.         if (!ComboBoxSomethingSelected( IDC_RESOLUTION_COMBO ) && 
  594.             ComboBoxCount( IDC_RESOLUTION_COMBO ) > 0)
  595.         {
  596.             ComboBoxSelectIndex( IDC_RESOLUTION_COMBO, 0 );
  597.         }
  598.     }
  599.  
  600.     // Update backbuffer format combo box
  601.     D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO );
  602.     if( pDeviceInfo == NULL )
  603.         return;
  604.     ComboBoxClear( IDC_BACKBUFFERFORMAT_COMBO );
  605.     for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ )
  606.     {
  607.         D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc);
  608.         if (pDeviceCombo->IsWindowed == m_d3dSettings.IsWindowed &&
  609.             pDeviceCombo->AdapterFormat == m_d3dSettings.DisplayMode().Format)
  610.         {
  611.             if (!ComboBoxContainsText( IDC_BACKBUFFERFORMAT_COMBO, 
  612.                 D3DUtil_D3DFormatToString( pDeviceCombo->BackBufferFormat ) ) )
  613.             {
  614.                 ComboBoxAdd( IDC_BACKBUFFERFORMAT_COMBO, (void*)pDeviceCombo->BackBufferFormat,
  615.                     D3DUtil_D3DFormatToString( pDeviceCombo->BackBufferFormat ) );
  616.                 if (pDeviceCombo->BackBufferFormat == m_d3dSettings.BackBufferFormat() )
  617.                     ComboBoxSelect( IDC_BACKBUFFERFORMAT_COMBO, (void*)pDeviceCombo->BackBufferFormat );
  618.             }
  619.         }
  620.     }
  621.     if (!ComboBoxSomethingSelected( IDC_BACKBUFFERFORMAT_COMBO ) && 
  622.         ComboBoxCount( IDC_BACKBUFFERFORMAT_COMBO ) > 0)
  623.     {
  624.         ComboBoxSelectIndex( IDC_BACKBUFFERFORMAT_COMBO, 0 );
  625.     }
  626. }
  627.  
  628.  
  629.  
  630.  
  631. //-----------------------------------------------------------------------------
  632. // Name: ResolutionChanged
  633. // Desc: Respond to a change of selected resolution by rebuilding the
  634. //       refresh rate list.
  635. //-----------------------------------------------------------------------------
  636. void CD3DSettingsDialog::ResolutionChanged( void )
  637. {
  638.     if (m_d3dSettings.IsWindowed)
  639.         return;
  640.  
  641.     D3DAdapterInfo* pAdapterInfo = (D3DAdapterInfo*)ComboBoxSelected( IDC_ADAPTER_COMBO );
  642.     if( pAdapterInfo == NULL )
  643.         return;
  644.  
  645.     // Update settingsNew with new resolution
  646.     DWORD dwResolutionData = PtrToUlong( ComboBoxSelected( IDC_RESOLUTION_COMBO ) );
  647.     UINT width = LOWORD( dwResolutionData );
  648.     UINT height = HIWORD( dwResolutionData );
  649.     m_d3dSettings.Fullscreen_DisplayMode.Width = width;
  650.     m_d3dSettings.Fullscreen_DisplayMode.Height = height;
  651.  
  652.     // Update refresh rate list based on new resolution
  653.     D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) );
  654.     ComboBoxClear( IDC_REFRESHRATE_COMBO );
  655.     for( UINT idm = 0; idm < pAdapterInfo->pDisplayModeList->Count(); idm++ )
  656.     {
  657.         D3DDISPLAYMODE displayMode = *(D3DDISPLAYMODE*)pAdapterInfo->pDisplayModeList->GetPtr(idm);
  658.         if (displayMode.Format == adapterFormat &&
  659.             displayMode.Width  == width &&
  660.             displayMode.Height == height)
  661.         {
  662.             TCHAR strRefreshRate[50];
  663.             if( displayMode.RefreshRate == 0 )
  664.                 lstrcpy( strRefreshRate, TEXT("Default Rate") );
  665.             else
  666.                 _sntprintf( strRefreshRate, 50, TEXT("%d Hz"), displayMode.RefreshRate );
  667.             strRefreshRate[49] = 0;
  668.             if( !ComboBoxContainsText( IDC_REFRESHRATE_COMBO, strRefreshRate ) )
  669.             {
  670.                 ComboBoxAdd( IDC_REFRESHRATE_COMBO, UlongToPtr( displayMode.RefreshRate ), strRefreshRate );
  671.                 if (m_d3dSettings.Fullscreen_DisplayMode.RefreshRate == displayMode.RefreshRate)
  672.                     ComboBoxSelect( IDC_REFRESHRATE_COMBO, UlongToPtr( displayMode.RefreshRate ) );
  673.             }
  674.         }
  675.     }
  676.     if (!ComboBoxSomethingSelected( IDC_REFRESHRATE_COMBO ) && 
  677.         ComboBoxCount( IDC_REFRESHRATE_COMBO ) > 0)
  678.     {
  679.         ComboBoxSelectIndex( IDC_REFRESHRATE_COMBO, 0 );
  680.     }
  681. }
  682.  
  683.  
  684.  
  685.  
  686. //-----------------------------------------------------------------------------
  687. // Name: RefreshRateChanged
  688. // Desc: Respond to a change of selected refresh rate.
  689. //-----------------------------------------------------------------------------
  690. void CD3DSettingsDialog::RefreshRateChanged( void )
  691. {
  692.     if( m_d3dSettings.IsWindowed )
  693.         return;
  694.  
  695.     // Update settingsNew with new refresh rate
  696.     UINT refreshRate = PtrToUlong( ComboBoxSelected( IDC_REFRESHRATE_COMBO ) );
  697.     m_d3dSettings.Fullscreen_DisplayMode.RefreshRate = refreshRate;
  698. }
  699.  
  700.  
  701.  
  702.  
  703. //-----------------------------------------------------------------------------
  704. // Name: BackBufferFormatChanged
  705. // Desc: Respond to a change of selected back buffer format by rebuilding
  706. //       the depth/stencil format list, multisample type list, and vertex
  707. //       processing type list.
  708. //-----------------------------------------------------------------------------
  709. void CD3DSettingsDialog::BackBufferFormatChanged( void )
  710. {
  711.     D3DDeviceInfo* pDeviceInfo = (D3DDeviceInfo*)ComboBoxSelected( IDC_DEVICE_COMBO );
  712.     D3DFORMAT adapterFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_ADAPTERFORMAT_COMBO ) );
  713.     D3DFORMAT backBufferFormat = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_BACKBUFFERFORMAT_COMBO ) );
  714.     if( pDeviceInfo == NULL )
  715.         return;
  716.  
  717.     for( UINT idc = 0; idc < pDeviceInfo->pDeviceComboList->Count(); idc++ )
  718.     {
  719.         D3DDeviceCombo* pDeviceCombo = (D3DDeviceCombo*)pDeviceInfo->pDeviceComboList->GetPtr(idc);
  720.         if (pDeviceCombo->IsWindowed == m_d3dSettings.IsWindowed &&
  721.             pDeviceCombo->AdapterFormat == adapterFormat &&
  722.             pDeviceCombo->BackBufferFormat == backBufferFormat)
  723.         {
  724.             if( m_d3dSettings.IsWindowed )
  725.                 m_d3dSettings.pWindowed_DeviceCombo = pDeviceCombo;
  726.             else
  727.                 m_d3dSettings.pFullscreen_DeviceCombo = pDeviceCombo;
  728.  
  729.             ComboBoxClear( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO );
  730.             if( m_pEnumeration->AppUsesDepthBuffer )
  731.             {
  732.                 for( UINT ifmt = 0; ifmt < pDeviceCombo->pDepthStencilFormatList->Count(); ifmt++ )
  733.                 {
  734.                     D3DFORMAT fmt = *(D3DFORMAT*)pDeviceCombo->pDepthStencilFormatList->GetPtr(ifmt);
  735.                     ComboBoxAdd( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, (void*)fmt, 
  736.                         D3DUtil_D3DFormatToString(fmt) );
  737.                     if( fmt == m_d3dSettings.DepthStencilBufferFormat() )
  738.                         ComboBoxSelect( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, (void*)fmt );
  739.                 }
  740.                 if (!ComboBoxSomethingSelected( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) && 
  741.                     ComboBoxCount( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) > 0)
  742.                 {
  743.                     ComboBoxSelectIndex( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, 0 );
  744.                 }
  745.             }
  746.             else
  747.             {
  748.                 EnableWindow( GetDlgItem( m_hDlg, IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ), false );
  749.                 ComboBoxAdd( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, NULL, TEXT("(not used)") );
  750.                 ComboBoxSelectIndex( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO, 0 );
  751.             }
  752.  
  753.             ComboBoxClear( IDC_VERTEXPROCESSING_COMBO );
  754.             for( UINT ivpt = 0; ivpt < pDeviceCombo->pVertexProcessingTypeList->Count(); ivpt++ )
  755.             {
  756.                 VertexProcessingType vpt = *(VertexProcessingType*)pDeviceCombo->pVertexProcessingTypeList->GetPtr(ivpt);
  757.                 ComboBoxAdd( IDC_VERTEXPROCESSING_COMBO, (void*)vpt, VertexProcessingTypeToString(vpt) );
  758.                 if( vpt == m_d3dSettings.GetVertexProcessingType() )
  759.                     ComboBoxSelect( IDC_VERTEXPROCESSING_COMBO, (void*)vpt );
  760.             }
  761.             if (!ComboBoxSomethingSelected( IDC_VERTEXPROCESSING_COMBO ) && 
  762.                 ComboBoxCount( IDC_VERTEXPROCESSING_COMBO ) > 0)
  763.             {
  764.                 ComboBoxSelectIndex( IDC_VERTEXPROCESSING_COMBO, 0 );
  765.             }
  766.  
  767.             ComboBoxClear( IDC_PRESENTINTERVAL_COMBO );
  768.             for( UINT ipi = 0; ipi < pDeviceCombo->pPresentIntervalList->Count(); ipi++ )
  769.             {
  770.                 UINT pi = *(UINT*)pDeviceCombo->pPresentIntervalList->GetPtr(ipi);
  771.                 ComboBoxAdd( IDC_PRESENTINTERVAL_COMBO, UlongToPtr( pi ), PresentIntervalToString(pi) );
  772.                 if( pi == m_d3dSettings.PresentInterval() )
  773.                     ComboBoxSelect( IDC_PRESENTINTERVAL_COMBO, UlongToPtr( pi ) );
  774.             }
  775.             if (!ComboBoxSomethingSelected( IDC_PRESENTINTERVAL_COMBO ) && 
  776.                 ComboBoxCount( IDC_PRESENTINTERVAL_COMBO ) > 0)
  777.             {
  778.                 ComboBoxSelectIndex( IDC_PRESENTINTERVAL_COMBO, 0 );
  779.             }
  780.  
  781.             break;
  782.         }
  783.     }
  784. }
  785.  
  786.  
  787.  
  788.  
  789. //-----------------------------------------------------------------------------
  790. // Name: DepthStencilBufferFormatChanged
  791. // Desc: Respond to a change of selected depth/stencil buffer format.
  792. //-----------------------------------------------------------------------------
  793. void CD3DSettingsDialog::DepthStencilBufferFormatChanged( void )
  794. {
  795.     D3DFORMAT fmt = (D3DFORMAT)PtrToUlong( ComboBoxSelected( IDC_DEPTHSTENCILBUFFERFORMAT_COMBO ) );
  796.     if( m_pEnumeration->AppUsesDepthBuffer )
  797.         m_d3dSettings.SetDepthStencilBufferFormat( fmt );
  798.  
  799.     // Build multisample list
  800.     D3DDeviceCombo* pDeviceCombo = m_d3dSettings.PDeviceCombo();
  801.     ComboBoxClear( IDC_MULTISAMPLE_COMBO );
  802.     for( UINT ims = 0; ims < pDeviceCombo->pMultiSampleTypeList->Count(); ims++ )
  803.     {
  804.         D3DMULTISAMPLE_TYPE msType = *(D3DMULTISAMPLE_TYPE*)pDeviceCombo->pMultiSampleTypeList->GetPtr(ims);
  805.  
  806.         // check for DS/MS conflicts
  807.         BOOL bConflictFound = FALSE;
  808.         for( UINT iConf = 0; iConf < pDeviceCombo->pDSMSConflictList->Count(); iConf++ )
  809.         {
  810.             D3DDSMSConflict* pDSMSConf = (D3DDSMSConflict*)pDeviceCombo->pDSMSConflictList->GetPtr(iConf);
  811.             if( pDSMSConf->DSFormat == fmt && pDSMSConf->MSType == msType )
  812.             {
  813.                 bConflictFound = TRUE;
  814.                 break;
  815.             }
  816.         }
  817.         if( !bConflictFound )
  818.         {
  819.             ComboBoxAdd( IDC_MULTISAMPLE_COMBO, (void*)msType, MultisampleTypeToString(msType) );
  820.             if( msType == m_d3dSettings.MultisampleType() )
  821.                 ComboBoxSelect( IDC_MULTISAMPLE_COMBO, (void*)msType );
  822.         }
  823.     }
  824.     if (!ComboBoxSomethingSelected( IDC_MULTISAMPLE_COMBO ) && 
  825.         ComboBoxCount( IDC_MULTISAMPLE_COMBO ) > 0)
  826.     {
  827.         ComboBoxSelectIndex( IDC_MULTISAMPLE_COMBO, 0 );
  828.     }
  829. }
  830.  
  831.  
  832.  
  833.  
  834.  
  835. //-----------------------------------------------------------------------------
  836. // Name: MultisampleTypeChanged
  837. // Desc: Respond to a change of selected multisample type.
  838. //-----------------------------------------------------------------------------
  839. void CD3DSettingsDialog::MultisampleTypeChanged( void )
  840. {
  841.     D3DMULTISAMPLE_TYPE mst = (D3DMULTISAMPLE_TYPE)PtrToUlong( ComboBoxSelected( IDC_MULTISAMPLE_COMBO ) );
  842.     m_d3dSettings.SetMultisampleType( mst );
  843.  
  844.     // Set up max quality for this mst
  845.     D3DDeviceCombo* pDeviceCombo = m_d3dSettings.PDeviceCombo();
  846.     DWORD maxQuality = 0;
  847.  
  848.     for( UINT ims = 0; ims < pDeviceCombo->pMultiSampleTypeList->Count(); ims++ )
  849.     {
  850.         D3DMULTISAMPLE_TYPE msType = *(D3DMULTISAMPLE_TYPE*)pDeviceCombo->pMultiSampleTypeList->GetPtr(ims);
  851.         if( msType == mst )
  852.         {
  853.             maxQuality = *(DWORD*)pDeviceCombo->pMultiSampleQualityList->GetPtr(ims);
  854.             break;
  855.         }
  856.     }
  857.  
  858.     ComboBoxClear( IDC_MULTISAMPLE_QUALITY_COMBO );
  859.     for( UINT msq = 0; msq < maxQuality; msq++ )
  860.     {
  861.         TCHAR str[100];
  862.         wsprintf( str, TEXT("%d"), msq );
  863.         ComboBoxAdd( IDC_MULTISAMPLE_QUALITY_COMBO, UlongToPtr( msq ), str );
  864.         if( msq == m_d3dSettings.MultisampleQuality() )
  865.             ComboBoxSelect( IDC_MULTISAMPLE_QUALITY_COMBO, UlongToPtr( msq ) );
  866.     }
  867.     if (!ComboBoxSomethingSelected( IDC_MULTISAMPLE_QUALITY_COMBO ) && 
  868.         ComboBoxCount( IDC_MULTISAMPLE_QUALITY_COMBO ) > 0)
  869.     {
  870.         ComboBoxSelectIndex( IDC_MULTISAMPLE_QUALITY_COMBO, 0 );
  871.     }
  872. }
  873.  
  874.  
  875.  
  876.  
  877. //-----------------------------------------------------------------------------
  878. // Name: MultisampleQualityChanged
  879. // Desc: Respond to a change of selected multisample quality.
  880. //-----------------------------------------------------------------------------
  881. void CD3DSettingsDialog::MultisampleQualityChanged( void )
  882. {
  883.     DWORD msq = (DWORD)PtrToUlong( ComboBoxSelected( IDC_MULTISAMPLE_QUALITY_COMBO ) );
  884.     m_d3dSettings.SetMultisampleQuality( msq );
  885. }
  886.  
  887.  
  888.  
  889.  
  890. //-----------------------------------------------------------------------------
  891. // Name: VertexProcessingChanged
  892. // Desc: Respond to a change of selected vertex processing type.
  893. //-----------------------------------------------------------------------------
  894. void CD3DSettingsDialog::VertexProcessingChanged( void )
  895. {
  896.     VertexProcessingType vpt = (VertexProcessingType)PtrToUlong( ComboBoxSelected( IDC_VERTEXPROCESSING_COMBO ) );
  897.     m_d3dSettings.SetVertexProcessingType( vpt );
  898. }
  899.  
  900.  
  901.  
  902.  
  903. //-----------------------------------------------------------------------------
  904. // Name: PresentIntervalChanged
  905. // Desc: Respond to a change of selected present interval.
  906. //-----------------------------------------------------------------------------
  907. void CD3DSettingsDialog::PresentIntervalChanged( void )
  908. {
  909.     UINT pi = PtrToUlong( ComboBoxSelected( IDC_PRESENTINTERVAL_COMBO ) );
  910.     m_d3dSettings.SetPresentInterval( pi );
  911. }
  912.